/**
 * @file	watchdog.h
 * @author	chipsea
 * @brief	
 * @version	0.1
 * @date	2020-11-30
 * @copyright Copyright (c) 2020, CHIPSEA Co., Ltd.
 * @note
 */
#ifndef __WATCHDOG_H__
#define __WATCHDOG_H__

#ifdef __cplusplus
extern "C" {
#endif

#include "types.h"

typedef enum {DISABLE = 0, ENABLE = !DISABLE} FunctionalState_t;

/// Callback function pointer type
typedef void (*pfnHdlCB_t)(void);

/**
 * @brief  wdt 溢出时间选择.
 */
typedef enum{
    WDG_2S =   0,
    WDG_4S =   1,
    WDG_8S =   2,
    WDG_16S =  3,
    WDG_32S =  4,
    WDG_64S =  5,
    WDG_128S = 6,
    WDG_256S = 7
}WDG_CYCLE_Type_e;

/**
* @enum WdtRspMode_t
* @brief wdt response mode struct
*/
typedef enum
{
	WDG_USE_POLLING_MODE = 0,		//this mode is recommended
	WDG_USE_INT_MODE	= 1, 		//when timeout, first generate an interrupt and if it is not cleared by the time a second timeout occurs,
									//then generate a system reset.timeout:about 4s(32.768Khz,0xffff~0,twice + Reset pulse length(pclk))
} WdtRspMode_t;


/* wdt overflow timer config*/
#define HAL_WDG_CFG_CYCLE		WDG_2S

/**
* @fn void HalWdtInit(FunctionalState_t newState, WdtRspMode_t mode, pfnHdlCB_t irqHdlCallback)
* @brief wdt initialize
* @param[in] newState: ENABLE or DISABLE
* @param[in] mode: WDT_RSP_MODE_NO_INT or WDT_RSP_MODE_INT
* @param[in] irqHdlCallback: interrupt handle callback
* @return none.
*/
void HalWdtInit(FunctionalState_t newState, WdtRspMode_t mode,pfnHdlCB_t irqHdlCallback);
/**
* @fn void HalWdtFeed(void)
* @brief wdt feed
* @param[in] none
* @return none.
*/

void HalWdtFeed(void);


#ifdef __cplusplus
}
#endif

#endif
